using System.Text;

namespace GameKit.Core
{
    public static class Log
    {
        private static ILogger _logger;

        public static void SetLogger(ILogger logger)
        {
            _logger = logger;
        }

        public static void Debug(params object[] messages)
        {
            _logger.Debug(BuildMessage(messages));
        }

        public static void Info(params object[] messages)
        {
            _logger.Info(BuildMessage(messages));
        }

        public static void Warn(params object[] messages)
        {
            _logger.Error(BuildMessage(messages));
        }

        public static void Error(params object[] messages)
        {
            _logger.Error(BuildMessage(messages));
        }

        private static string BuildMessage(params object[] messages)
        {
            var sb = new StringBuilder();
            for (var i = 0; i < messages.Length; i++)
            {
                sb.Append(messages[i]);
                if (i != messages.Length - 1)
                {
                    sb.Append(",");
                }
            }

            return sb.ToString();
        }
    }
}